package leetcode.presum;

public class Lc1732 {

    public int largestAltitude(int[] gain) {
        int[] d = new int[gain.length + 1];
        d[0] = 0;
        int ans = 0;
        for (int i = 1; i <= gain.length; i++) {
            d[i] = d[i - 1] + gain[i - 1];
            ans = Math.max(ans, d[i]);
        }
        return ans;
    }
}
